//
//  PhoneValidatorTests.swift
//  User
//
//  Created by ET|冰琳 on 2017/1/9.
//  Copyright © 2017年 IB. All rights reserved.
//

import XCTest
@testable import User

class PhoneValidatorTests: XCTestCase {
    
    let validator = PhoneValidator()
    
    override func setUp() {
        super.setUp()
        // Put setup code here. This method is called before the invocation of each test method in the class.
    }
    
    override func tearDown() {
        // Put teardown code here. This method is called after the invocation of each test method in the class.
        super.tearDown()
    }
    
    func testEmptyExample() {
        let empty:String? = nil
        let validate  = validator.validate(txt: empty)
        XCTAssert(validate == false, "空字符串 不合法")
    }
    
    func testLengthGreaterThan() {
        let length12 = "134123412341"
        let validate = validator.validate(txt: length12)
        XCTAssert(validate == false, "手机号长度 > 11 验证")
    }
    
    func testLengthLessThan(){
        let length10 = "1331234123"
        let validate = validator.validate(txt: length10)
        XCTAssert(validate == false, "手机长度 < 11验证")
    }
    
    func testValidePhone(){
        let validePhone = "13761992653"
        let valide = validator.validate(txt: validePhone)
        XCTAssert(valide == true, "手机号码正确")
    }
    
    func testLengthValideAndPhoneError() {
        let invalidePhone = "12712341234"
        let valide = validator.validate(txt: invalidePhone)
        XCTAssert(valide == false, "手机号码长度正确 号码错误")
    }
    
}
